<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/common/page_init.jsp"%>
<%
	JSONObject result = (JSONObject)request.getAttribute("result");
	JSONArray adapterGather = new JSONArray();
	String nodeId = (String)request.getAttribute("nodeId");
	String nodeType = (String)request.getAttribute("nodeType");
	String ESB_CORE_VERSION = (String)request.getAttribute("ESB_CORE_VERSION");
	String V;
	int AdapterCount=0;
	JSONObject nodeJson = new JSONObject();
	int nodeCount = nodeType.equals("esb")?result.getIntValue("esb_nodeCount"):result.getIntValue("ifs_nodeCount");
	if(nodeCount>0) {
		JSONArray esb_records = nodeType.equals("esb") ? result.getJSONArray("esb_records") : result.getJSONArray("ifs_records");
		for (int m = 0; m < esb_records.size(); m++) {
			JSONObject row1 = esb_records.getJSONObject(m);
			if (row1.getString("nodeId").equals(nodeId)) {

				if (nodeType.equals("esb")) {
					V = ESB_CORE_VERSION;
					row1.put("version",V);
				} else {
					V = row1.getString("version");
					row1.put("version",V);
				}
				nodeJson = row1;
			}
		}
	}





	if(nodeType.equals("esb")) {
		JSONObject adapterRst = (JSONObject) request.getAttribute("adapterRst");
		int count = adapterRst.getIntValue("count");
		if (count > 0) {
			JSONArray records = adapterRst.getJSONArray("records");
			for (int i = 0; i < count; i++) {
				JSONObject row = records.getJSONObject(i);
				if (row.getIntValue("code") > -1) {
					int nodeAdapterCount = row.getJSONObject("adapterList").getIntValue("count");
					if (nodeAdapterCount > 0) {
						JSONArray adapterRecords = row.getJSONObject("adapterList").getJSONArray("records");

						AdapterCount+=adapterRecords.size();

						for (int j = 0; j < nodeAdapterCount; j++) {
							JSONObject adapterRow = adapterRecords.getJSONObject(j);
							adapterGather.add(adapterRow);
						}
					}
				}
			}
		}
	}


%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><%=CommonConfig.getString("SYSTEM_TITLE")%></title>
	<script src="<%=contextPath%>/js/common/plug-in/highCharts/highcharts.js"></script>
	<script type="text/javascript" src="<%=contextPath%>/js/console/monitor/nodeView.js?uuid=<%=RANDOM%>"></script>
	<script type="text/javascript">
		var result = <%=result%>;
		var AdapterCount =<%=AdapterCount%>
		var adapterGather = <%=adapterGather%>;
		var nodeJson = <%=nodeJson%>;
		var nodeId = "<%=nodeId%>";
		var nodeType = "<%=nodeType%>";
				$(".node-state").height( $(window).height());
		$(".node-state-detail").height( $(window).height());
	</script>
</head>
<body>

<div class="main-nav">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="50%" valign="top">
				<div class="node-state easyui-layout" data-options="fit:true">
					<div data-options="region:'north',border:false" height="90px">
						<div id="esbNodeContainer">
							<table id="esbNodeTable" width="100%" border="0" cellspacing="0" cellpadding="0" class="content-table">
							</table>
						</div>
					</div>
					<div data-options="region:'center',border:false">
						<table border="0" width="100%" cellspacing="0" cellpadding="0" id="nodeAdapterDg">
						</table>
					</div>
					<div data-options="region:'south',border:false" height="170px">
						<div class="operate-contant easyui-panel" data-options="title:'线程池监控'">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td width="25%">总线程</td>
									<td width="25%" id="Threads"></td>
									<td width="25%">正在使用线程</td>
									<td width="25%" id="UseThreads"></td>
								</tr>
								<tr>
									<td>空闲线程</td>
									<td id="IdleThreads"></td>
									<td>最小线程</td>
									<td id="MinThreads"></td>
								</tr>
								<tr>
									<td>最大线程</td>
									<td id="MaxThreads"></td>
									<td>空闲超时时间</td>
									<td id="IdleTimeout"></td>
								</tr>
							</table>
						</div>

					</div>
				</div>
			</td>

			<td class="bor-left" width="50%" valign="top">
				<div class="node-state-detail">
					<div class="node-state-detail-nav">
						<div class="pl5 pr5 pb5">
							<div class="sj-tatol mt5" style="width: 100%; height: 200px;" id="container_1">
							</div>
							<div class="sj-tatol mt5" style="width: 100%; height: 200px;" id="container_2">
							</div>
							<div class="sj-tatol mt5" style="width: 100%; height: 200px;" id="container_3">
							</div>
						</div>
					</div>
				</div>
			</td>
		</tr>
	</table>
</div>
<script type="text/javascript">
	$(".node-state").height( $(window).height());
	$(".node-state-detail").height( $(window).height());
</script>
</body>
</html>